package tests;

import static org.junit.Assert.*;

import java.net.Socket;

import model.Client;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * This class tests the Client class.
 
 * 
 * @author b_aldosa
 * @since June 17, 2013
 *
 */
public class TestClient {

	Client SUT;
	Socket socket;
	
	/**
	 * This method is called before every test case to initialize 
	 * a new socket and a Client object.
	 */
	@Before
	public void setUp()
	{
		socket=new Socket();
		SUT=new Client("client", socket);
	}
	/**
	 * This method is called after every test case to 
	 * nullify objects.
	 */
	@After
	public void tearDown()
	{
		socket=null;
		SUT=null;
	}
	/**
	 * This test case tests the get name method
	 */
	@Test
	public void testGetName() 
	{
		String result=SUT.getName();
		assertEquals("client",result);
	}
	/**
	 * This test case tests the get socket method
	 */
	@Test
	public void testGetSocket() {
		assertEquals(socket,SUT.getSocket());
	}
	/**
	 * This test case tests the set socket method
	 */
	@Test
	public void testSetSocket() {
		Socket newSocket=new Socket();
		SUT.setSocket(newSocket);
		assertEquals(newSocket,SUT.getSocket());
	}

}
